<@_sysRole id=id>
    <#assign a=object/>
</@_sysRole>
<form method="post" autocomplete="off" action="sysRole/save?callbackType=closeCurrent&navTabId=sysRole/list" class="pageForm required-validate" onsubmit="return validateCallback(this, navTabAjaxDone);">
    <input name="id" type="hidden" value="${id!}" />
    <input type="hidden" name="_csrf" value="<@_csrfToken admin=true/>"/>
    <div class="formBar">
        <ul>
            <li><button type="submit" class="buttonActive"><@t.page 'button.save'/></button></li>
            <li><button type="button" class="button close"><@t.page 'button.close'/></button></li>
        </ul>
    </div>
    <div class="pageFormContent" layoutH>
        <dl class="nowrap">
            <dt><@t.page 'name'/>:</dt>
            <dd>
                <input class="required" name="name" type="text" maxlength="20" size="20" value="${(a.name)!}"/>
            </dd>
        </dl>
        <dl class="nowrap">
            <dt><@t.page 'module.own_all_right'/>:</dt>
            <dd>
                <input name="ownsAllRight" type="checkbox" onclick="if($(this).is(':checked')){$('.ownsAllRight',navTab.getCurrentPanel()).hide();}else{$('.ownsAllRight').show();}"/>
            </dd>
        </dl>
<#macro moduleTree parentId='' deep=0>
    <@_sysModuleList parentId=parentId advanced=true>
        <#if page.totalCount gt 0>
            <ul>
                <#list page.list as a>
                    <li>
                        <a tname="moduleIds" tvalue="${a.id}"><#if (a.attached)?has_content><i class="${a.attached} icon-large"></i></#if> <@t.menu a.id/></a>
                        <#if deep lte 3>
                            <@moduleTree a.id deep+1/>
                        </#if>
                    </li>
                </#list>
            </ul>
        </#if>
    </@_sysModuleList>
</#macro>
        <fieldset class="ownsAllRight">
            <legend><@t.page 'module'/></legend>
            <dl class="nowrap">
                <dt><@t.page 'module.show_all_module'/>:</dt>
                <dd>
                    <input name="showAllModule" type="checkbox"/>
                </dd>
            </dl>
            <ul class="tree treeFolder treeCheck">
                <li>
                    <a href="javascript:;" onclick="return false;"><@t.page 'module.all'/></a>
                    <@moduleTree deep=0/>
                </li>
            </ul>
<#if a??>
<script>
    <#if a.ownsAllRight>
    $('input[name=ownsAllRight]',navTab.getCurrentPanel()).click();
    </#if>
    <#if a.showAllModule>
    $('input[name=showAllModule]',navTab.getCurrentPanel()).click();
    </#if>
    <@_sysRoleModuleList roleId=a.id>
        <#list page.list as a>
    $('.tree li a[tname=moduleIds][tvalue=${a.id.moduleId?js_string}]',navTab.getCurrentPanel()).prop('checked',true);
        </#list>
    </@_sysRoleModuleList>
</script>
</#if>
        </fieldset>
    </div>
</form>